package com.example.spingbootvue.mapper;

import com.example.spingbootvue.entity.Resumemsg;
import com.example.spingbootvue.entity.employeemessage;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface UserResumeMapper {

    //查询简历中基本信息以及个人优势信息
    @Select("select * from user_biographical_notes where account = #{account}")
    List<Resumemsg> selectresumemsg(String account);

    //更新简历的个人基本信息(name,sex..advantage)
    @Update("update user_biographical_notes set name=#{name},sex=#{sex},age=#{age},phone=#{phone},position=#{position},address=#{address},intendjob=#{intendjob} WHERE account= #{account}")
    int  updateuserresumemsg(String name, String sex, Integer age, String phone, String position, String address, String intendjob,String account);

    //更新简历个人信息的advantage
    @Update("update user_biographical_notes set advantage=#{advantage} WHERE account= #{account}")
    int  updatebuaccount(String advantage,String account);

    //更新简历工作/实习经历信息
    @Update("UPDATE user_biographical_notes SET  experiencename=#{experiencename},experience=#{experience}WHERE account=#{account}")
    int updateexperience(String experiencename,String experience,String account);

    //更新赛事获奖信息
    @Update("UPDATE user_biographical_notes SET  matchname=#{matchname},matchintroduction=#{matchintroduction}WHERE account=#{account}")
    int updatematch(String matchname,String matchintroduction,String account);

    //注册页面新用户注册在数据库user_biographical_notes表中仅插入account属性值
    @Insert("INSERT INTO user_biographical_notes (account) VALUES (#{account})")
    int insertaccount(String account);

    //简历箱界面展示HR发布的招聘信息有哪些招聘者投递简历
    @Select("SELECT  * FROM employeeapply WHERE account = #{account}")
    List<employeemessage> selectemployeemessage(String account);

    //个人主页界面点击按钮将账号插入user_biographical_notes表
    @Insert("Insert INTO user_biographical_notes (account) VALUES (#{account})")
    int insertbyaccount(String account);

    //查询是否已经有此用户账号编辑了简历
    @Select("SELECT * FROM user_biographical_notes WHERE account=#{account} limit 1")
    Resumemsg selectaccount(String account);

    //简历箱中点击查看简历查询对应用户账户的信息
    @Select("SELECT * FROM user_biographical_notes WHERE account=#{account}")
    Resumemsg querybyaccount(String account);

    //简历箱中HR点击发送offer插入文件地址在employeeapply表
    @Update("UPDATE employeeapply SET offer=#{offer} WHERE id=#{id}")
    int updateoffer(String offer,Integer id);

    //查询是否以及发送了offer
    @Select("SELECT * FROM employeeapply WHERE offer=#{offer} limit 1")
    Resumemsg selectoffer(String offer);

    //用户简历box中查询公司发送的offer
    @Select("SELECT * FROM employeeapply WHERE applicantaccount = #{applicantaccount} AND offer IS NOT NULL")
    List<employeemessage> selectuseroffer(String applicantaccount);
}
